// 全局共享数据示例
import { DEFAULT_NAME } from '@/constants';
import { useState, useEffect } from 'react';
import { CurrentUser, MenuItem, getCurrentUser, getMenuData } from '@/services/auth';

const useUser = () => {
  const [name, setName] = useState<string>(DEFAULT_NAME);

  useEffect(() => {
    // 获取用户信息
    const fetchUserInfo = async () => {
      const userInfo = await getCurrentUser();
      setName(userInfo.name);
    };

    fetchUserInfo();
  }, []);

  return {
    name,
    setName,
  };
};

export default useUser;
